{template 'aitimt/common/header'}
<link rel="stylesheet" type="text/css" href="{$aideUrl}app/resource/components/mui/mui.ext.css?v=201802119">
<style type="text/css">
    .mui-bar a{color: #ff9900;}
    .top-return{left: 10px}
    .mui-bar-nav{height:7%;}
    .mui-btn-primary{background-color: #ff9900;}
    .mui-btn-primary:enabled:active{background-color: #ec7230!important;}
    .mui-textarea{ height:auto!important; width:100%;}
    .area {margin: 20px auto 0px auto;}
    .mui-input-group:first-child {margin-top: 20px;}
    .mui-rmb i{ font-style:normal; }
    .mui-input-row label~input, .mui-input-row label~select, .mui-input-row label~textarea {width: 65%;font-size: 12px;}
    .mui-del{color:#999}
    #popover{z-index: 9999}
    .mui-input-row label, .mui-input-row .mui-label{font-size: 12px;}
    footer .mui-input-row label{line-height:2!important; padding:11px 0; text-align:right; float:right;}
    footer .mui-input-row span{line-height:1.7; padding:11px 10px 11px 0;}
    footer .mui-input-row .mui-btn{top: 0; font-size:16px;line-height:1.6!important;border-radius:0; width:35%}
    .mui-input-row #get_code{width:auto; border-radius: 0;line-height: 1.7;}
    .mui-help-top .mui-table-view-cell{padding: 9px 12px;}
    .mui-help-top .mui-icon-help:before{ color:#fe5001; font-size:18px;}
    .mui-help-top .mui-small{ font-size:90%!important;}
    .mui-help-top .mui-help-info:before{position: absolute;content: ""; height:99%!important;left:0;top:0;width:3px; background-color:#fe5001;}
    .mui-input-row.mui-help .mui-help-info{padding-right:30px;}
    [data-type=date] .mui-dtpicker-title h5, [data-type=date] .mui-picker{width: 20%!important;}
    .mui-dtpicker-title h5,.mui-picker{ display:inline-block!important;}
    .mui-popover{position: fixed;}
    .mui-table-view .mui-media-object.mui-pull-left{max-width: 75px;height: 55px;}
    .mui-content>.mui-table-view:first-child{margin: 0;}
    .entry-pro {font-weight: 500;font-size: 15px;color: #000000;background-color: #FFFFFF;padding: 10px 0 1px 5%;}
    .entry-select{position: absolute;width: 95%;height: 4%;border: 1px solid #bcbcbc;margin-bottom: 10px;}
    .mui-btn-block{font-size: 14px;margin: 0;padding: 0;padding-left: 4%;line-height: 25px;color: #ffffff;}
    .mui-btn-block option:first-child{font-size: 14px;margin: 0;padding: 0;color: #bcbcbc;}
    .addtime{padding-top: 10px;font-size: 10px;}
    .formBtn{width: 15%;font-size: 10px;margin-top: 7px;padding:3px 12px;border-radius: 20px;border:1px dashed #8c8ee5}
    .formBtn-active{color: white;background: #E94709;border:1px solid #ff6f02;}
</style>
<header class="mui-bar mui-bar-nav">
    <a class="top-return mui-action-back"><img src="{$aideUrl}app/resource/aitimt/images/return.png" ></a>
    <a class="top-logo"><img src="{$aideUrl}app/resource/aitimt/images/logo.png" ></a>
    <!--公共菜单start -->
    {template 'aitimt/common/menu'}
    <!-- 公共菜单end-->
</header>
<!-- 公共头部end -->
<div class="mui-content">
    <ul class="mui-table-view">
        <li class="mui-table-view-cell mui-media">
            <img class="mui-media-object mui-pull-left" src="{php echo tomedia($activity['thumb']);}">
            <div class="mui-media-body">
                <h4 style="color: #595757;margin-top: 10px;">{$activity['title']}</h4>
                <p class=" mui-icon iconfont icon-riqi addtime">{$activity['starttime']}</p>
                <p class=" mui-icon iconfont icon-didian addtime">{$activity['address']}</p>
            </div>
        </li>
    </ul>
    <div style="font-size: 15px;color: #e94709;margin-left: 5%;font-weight: 500;" >
        报名项目
    </div>
    <div class="entry-pro">
        <p>报名项目:&nbsp;&nbsp;{$prodata[0]['name']}</p>
        <p>报名费用:&nbsp;&nbsp;{if $price>0}{$price}元{else}免费{/if}</p>
    </div>
<form id="formdata" action="" method="post" onSubmit="return check(this)" style="position: initial">
    <footer class="mui-bar mui-bar-footer"{if $price>0} style="padding:0;height:44px;"{/if}>
        {if $price>0}
        <div class="mui-input-row">
            <button type="submit" class="mui-btn mui-btn-orange" name="submit">下一步</button>
            <span class="mui-pull-right mui-text-rmb"><font class="mui-rmb mui-small"></font> <font class="mui-big js-pay-totaled">{$pay_price}</font> </span>
            <label>合计：</label>
        </div>
        {else}
        <button type="submit" class="mui-btn mui-btn-orange mui-btn-block" name="submit">下一步</button>
        {/if}
        <input type="hidden" name="submit" value="下一步" />
        <input type="hidden" name="activityid" value="{$activityid}" />
        <input type="hidden" name="proid" value="{$proid}" />
        {if !empty($_GPC['recordid'])}
        <input type="hidden" name="recordid" value="{$_GPC['recordid']}" />
        {/if}
        <input type="hidden" name="token" value="{$_W['token']}" />
    </footer>
    <div class="mui-content">
        <div class="mui-content-padded">
            <p>基本信息</p>
        </div>
        <div class="mui-input-row">
            <label>常用报名人选择:</label>
            {loop  $commendList $k $commend}
            <button type="button" class="formBtn {if $cid==$commend['id']}formBtn-active{/if}" onclick="formChange({$commend['id']})">
                {$commend['remarks']}
            </button>
            {/loop}
        </div>
        <div class="mui-input-group">
            {if $sysform['realname']['show']!='0'}
            <div class="mui-input-row">
                <label>{$sysform['realname']['title']}</label>
                <input type="text" name="member[realname]" id="realname" placeholder="{$sysform['realname']['title']} (必填)" value="{$profile['realname']}">
            </div>
            <div class="mui-input-row" style="display: none">
                <input type="text" name="member[pic]"  value="{$profile['avatar']}">
            </div>
            {/if}
            {if $sysform['mobile']['show']!='0'}
            <div class="mui-input-row mui-help">
                <label>{$sysform['mobile']['title']}</label>
                <input type="number" name="member[mobile]" id="mobile" placeholder="{$sysform['mobile']['title']} (必填)" pattern="[0-9]*" value="{$profile['mobile']}"/>
                {if !empty($profile['mobile']) && $_W['_config']['smsswitch']}
                <div class="mui-help-info mui-navigate-right mui-text-right js-check-mobile"><span class="mui-badge mui-badge-inverted">点此变更</span></div>
                {/if}
            </div>
            {/if}
        {if !empty($sysform)}
        {php $sys_form = array_slice($sysform, 2);}
        {loop $sys_form $k $v}
        {php $placeholder = $v['need'] ? $v['title'] . ' (必填)':$v['title'];}
        {if $k=='gender' && ($v['show']==='' || $v['show'])}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            {php echo tpl_app_fans_form('gender', $profile['gender'], $placeholder);}
        </div>
        {elseif $k=='age'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            <input type="number" name="member[{$k}]" value="{$profile['age']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
        </div>
        {elseif $k=='birthyear' && ($v['show']==='' || $v['show'])}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            {php echo tpl_app_fans_form('birth', array('year' => $profile['birthyear'], 'month' => $profile['birthmonth'], 'day' => $profile['birthday']), $placeholder);}
        </div>
        {elseif $k=='idcard'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            <input type="text" name="member[{$k}]" value="{$profile['idcard']}" placeholder="请填写{$placeholder}">
        </div>
        {elseif $k=='education'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            {php echo tpl_app_fans_form('education',$profile['education'],$placeholder);}
        </div>
        {elseif $k=='company'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            <input type="text" name="member[{$k}]" value="{$profile['company']}" placeholder="请填写{$placeholder}">
        </div>
        {elseif $k=='position'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            <input type="text" name="member[{$k}]" value="{$profile['position']}" placeholder="请填写{$placeholder}">
        </div>
        {elseif $k=='occupation'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            <input type="text" name="member[{$k}]" value="{$profile['occupation']}" placeholder="请填写{$placeholder}">
        </div>
        {elseif $k=='email'}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            <input type="text" name="member[{$k}]" value="{$profile['email']}" placeholder="请填写{$placeholder}">
        </div>
        {elseif $k=='resideprovince' && ($v['show']==='' || $v['show'])}
        <div class="mui-input-row">
            <label>{$v['title']}</label>
            {php echo tpl_app_fans_form('reside', array('province' => $profile['resideprovince'], 'city' => $profile['residecity'], 'district' => $profile['residedist']), $placeholder);}
        </div>
        {/if}
        {/loop}
        {/if}
        {php $key = 0;}
        {loop $activityForm[0] $k $form}
        {if !empty($form['fieldstype'])}
        {if $form['essential']==1}<input name="essential" type="hidden" value="" title="{$form['title']}" data-type="{$form['fieldstype']}"/>{/if}
        {php $placeholder = $form['essential']==1 ? $form['title'] . ' (必填)':$form['title'];}
        <div class="mui-input-row{if $form['essential']==1} js-check-fields{/if}" data-title="{$form['title']}" data-type="{$form['fieldstype']}">
            {if $form['fieldstype']=='age'}
            <label>{$form['title']}</label>
            <input type="number" name="member[{$form[fieldstype]}]" value="{$profile['age']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
            {elseif $form['fieldstype']=='studentid'}
            <label>{$form['title']}</label>
            <input type="number" name="member[studentid]" value="{$profile['studentid']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
            {elseif $form['fieldstype']=='zipcode'}
            <label>{$form['title']}</label>
            <input type="number" name="member[zipcode]" value="{$profile['zipcode']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
            {elseif $form['fieldstype']=='qq'}
            <label>{$form['title']}</label>
            <input type="number" name="member[qq]" value="{$profile['qq']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
            {elseif $form['fieldstype']=='weight'}
            {php $placeholder = $form['essential']==1 ? $form['title'] . '：单位kg' . ' (必填)':$form['title'];}
            <label>{$form['title']}</label>
            <input type="number" name="member[weight]" value="{$profile['weight']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
            {elseif $form['fieldstype']=='height'}
            {php $placeholder = $form['essential']==1 ? $form['title'] . '：单位cm' . ' (必填)':$form['title'];}
            <label>{$form['title']}</label>
            <input type="number" name="member[height]" value="{$profile['height']}" placeholder="请填写{$placeholder}" pattern="[0-9]*">
            {elseif $form['fieldstype']=='gender'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('gender', $profile['gender'], $placeholder);}
            {elseif $form['fieldstype']=='birthyear'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('birth', array('year' => $profile['birthyear'], 'month' => $profile['birthmonth'], 'day' => $profile['birthday']), $placeholder);}
            {elseif $form['fieldstype']=='resideprovince'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('reside', array('province' => $profile['resideprovince'], 'city' => $profile['residecity'], 'district' => $profile['residedist']), $placeholder);}
            {elseif $form['fieldstype']=='education'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('education', $profile['education'], $placeholder);}
            {elseif $form['fieldstype']=='constellation'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('constellation', $profile['constellation'], $placeholder);}
            {elseif $form['fieldstype']=='zodiac'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('zodiac', $profile['zodiac'], $placeholder);}
            {elseif $form['fieldstype']=='bloodtype'}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('bloodtype', $profile['bloodtype'], $placeholder);}
            {else}
            <label>{$form['title']}</label>
            {php echo tpl_app_fans_form('member['.$form['fieldstype'].']', $profile[$form['fieldstype']], $placeholder);}
            {/if}
        </div>
        {else}
        <input name="form_id[]" type="hidden" class="form-control form_id" value="{$form['id']}"/>
        {if $form['essential']==1}
        <input name="essential" type="hidden" value="{$key}" title="{$form['title']}" data-type="{$form['displaytype']}"/>
        {/if}
        {if $form['displaytype']==0}
        <h5 class="mui-desc-title mui-pl15">请选择{$form['title']}{if $form['essential']==1} <span class="mui-text-error">(必选)</span>{/if}</h5>
        {loop $form['items'] $formitem}
        <div class="mui-input-row mui-radio">
            <label>{$formitem['title']}</label>
            <input name="form_item_val_{$key}" type="radio" value="{$formitem['title']}">
        </div>
        {/loop}
        <p></p>
        {elseif $form['displaytype']==1}
        <h5 class="mui-desc-title mui-pl15">请选择{$form['title']}(可多选){if $form['essential']==1} <span class="mui-text-error">*</span>{/if}</h5>
        {loop $form['items'] $formitem}
        <div class="mui-input-row mui-checkbox">
            <label>{$formitem['title']}</label>
            <input name="form_item_val_{$key}[]" value="{$formitem['title']}" type="checkbox">
        </div>
        {/loop}
        <p></p>
        {elseif $form['displaytype']==2}
        <div class="mui-input-row">
            <label>{$form['title']}</label>
            <input class="form_item_val_{$k}" name="form_item_val_{$key}" type="text" value="" readonly placeholder="请选择{$form['title']}{if $form['essential']==1} (必选){/if}">
            <script type="text/javascript">
                $(".form_item_val_{$k}").on("tap", function(){
                    var options = {data: [
                            {loop $form['items'] $formitem}
                            {"text":"{$formitem['title']}","value":"{$formitem['title']}"},
                            {/loop}
                        ]};
                    var $this = $(this);
                    util.poppicker(options, function(items){
                        $this.val(items[0].value);
                    });
                });
            </script>
        </div>
        {elseif $form['displaytype']==3}
        <div class="mui-input-row">
            <label>{$form['title']}</label>
            <input name="form_item_val_{$key}" value="" type="text"  placeholder="请输入{$form['title']}{if $form['essential']==1} (必填){/if}">
        </div>
        {elseif $form['displaytype']==4}
        <div class="mui-input-row">
            <label>{$form['title']}</label>
            <input name="form_item_val_{$key}" value="" type="number"  placeholder="请输入{$form['title']}{if $form['essential']==1} (必填){/if}" pattern="[0-9]*">
        </div>
        {elseif $form['displaytype']==5}
        <p></p>
        <div class="mui-input-cell">
            <div class="mui-table-view-chevron">
                <div class="mui-image-uploader">
                    <div class="mui-image-preview js-image-preview{$key}">
                        <div class="file-item js-thumb" style="display:none;">
                            <img src="{$aideUrl}app/resource/images/nopic.jpg" data-id="" data-preview-src="" data-preview-group="__IMG_UPLOAD_pic"/>
                            <input type="hidden" value="" id="pic{$key}" name="form_item_val_{$key}" />
                        </div>
                    </div>
                    <a href="javascript:;" class="mui-upload-btn js-image-pic{$key} mui-inline"></a>
                </div>
                <script>
                    var obj{$key}=".js-image-pic{$key}";
                    util.img(obj{$key}, function(url){
                        $(obj{$key}).parent().find('.js-image-preview{$key}').find('#pic{$key}').val(url.attachment);
                        $(obj{$key}).parent().find('.js-image-preview{$key}').find('img').attr("src",url.url);
                        $(obj{$key}).parent().find('.js-image-preview{$key}').find('img').attr("data-id",url.id);
                        $(obj{$key}).parent().find('.js-image-preview{$key}').find('img').attr("data-preview-src",url.url);
                        $(obj{$key}).parent().find('.js-image-preview{$key}').find('.js-thumb').show();
                        $("input[name='token']"). val(url.token);
                    }, {
                        crop : true,
                            multiple : false,
                            preview : '__IMG_UPLOAD_pic',
                            pxSize : 640,
                            aspectRatio:{$_W['_config']['image']['ratio']},
                        resizable:1
                    });
                    setTimeout(function(){
                        $(obj{$key}).append('<div class="btn-intro" style="position:absolute;color:#d7d7d7;top:54px;line-height: 1.2; left:0; right:0;">上传{$form['title']}<br>(最多1张{if $form['essential']==1 }*{/if})</div>')
                    },1000);
                </script>
            </div>
        </div>
        <p></p>
        {elseif $form['displaytype']==6}
        <p></p>
        <div class="mui-input-cell">
            <div class="mui-table-view-chevron">
                <div class="mui-image-uploader">
                    <div class="mui-image-preview js-image-nopic mui-pull-left" style="display:none">
                        <img src="{$aideUrl}app/resource/images/nopic.jpg"/>
                    </div>
                    <div class="mui-image-preview js-image-preview{$key}"></div>
                    <a href="javascript:;" class="mui-upload-btn js-image-pic{$key} mui-inline"></a>
                </div>
                <script>
                    var obj{$key}=".js-image-pic{$key}";
                    util.img(obj{$key}, function(url){
                        $(obj{$key}).parent().find('.js-image-preview{$key}').append('<div class="file-item js-thumb"><input type="hidden" value="'+url.attachment+'" name="form_item_val_{$key}[]" /><img src="'+url.url+'" data-id="'+url.id+'" data-preview-src="" data-preview-group="__IMG_UPLOAD_image" /></div>');
                        $(".js-image-nopic").hide();
                        $("input[name='token']"). val(url.token);
                    }, {
                        crop : true,
                            multiple : true,
                            preview : '__IMG_UPLOAD_pic',
                            pxSize : 640,
                            aspectRatio:{$_W['_config']['image']['ratio']},
                        resizable:1
                    });
                    setTimeout(function(){
                        $(obj{$key}).append('<div class="btn-intro" style="position:absolute;color:#d7d7d7;top:54px;line-height: 1.2; left:0; right:0;">上传{$form['title']}<br>(最多8张{if $form['essential']==1 }*{/if})</div>')
                    },1000);
                </script>
            </div>
        </div>
        <p></p>
        {elseif $form['displaytype']==7}
        <div class="mui-input-row js-calendar-{$key}">
            <label>{$form['title']}</label>
            <input class="mui-calendar-picker{$key}" type="text" placeholder="请选择{$form['title']}{if $form['essential']==1} (必选){/if}" value="" readonly>
            <input type="hidden" value="" name="form_item_val_{$key}">
            <script type="text/javascript">
                $(document).on("tap", ".mui-calendar-picker{$key}", function(){
                    var $this = $(this);
                    util.poppicker({type: "date", beginYear: 2000, endYear: 2050}, function(rs){
                        $this.val(rs.value + ' ' + rs.h.value + ':' + rs.i.value)
                            .next().val(rs.value + ' ' + rs.h.value + ':' + rs.i.value)
                    });
                });
            </script>
        </div>
        {elseif $form['displaytype']==8}
        <div class="mui-input-row">
            <label>{$form['title']}{if $form['essential']==1}<span class="mui-text-error">*</span>{/if}</label>
            {php echo tpl_app_form_field_district('form_item_val_'.$key, array('province' => '','city' => '','district' => ''));}
        </div>
        {/if}
        {php $key++;}
        {/if}
        {/loop}
        {if $_W['container']=='wechat' && $activity['has_record_image']==1}
        <!--此段已删除，不用jssdk上传-->
        <div class="mui-input-row" style="height:auto;display:none">
            <label>人脸录入</label>
            <!--<input type="button" class="mui-btn mui-btn-primary" id="chooseImage" value="选择图片">-->
            <button class="mui-btn-success" type="button" id="chooseImage">选择图片</button>
            <div id="imageContainer"><ul></ul></div>
            <input type="hidden" id="serverIds" name="serverIds" value="">
        </div>

        <p></p>
        <div class="mui-input-cell">
            <div class="mui-table-view-chevron">
                <div class="lurutxt"><p>人脸录入</p></div>
                <div class="mui-image-uploader">
                    <input type ="file" id="ImportPicInput" name= "jianlu" accept="image/*" style="display: none" />
                    {if empty($record['imageurl'])}
                    <div class ="input-append">
                        <div class ="headpic" onclick= "$('#ImportPicInput').click();">
                            <img src="{$aideUrl}app/resource/images/headpic.png" />
                        </div>
                        <div class="faceimg_errmsg">
                        </div>
                    </div >
                    <input id="faceimg_id" type="hidden" name="faceimg_id" value="0"/>
                    {else}
                    <div class ="input-append">
                        <div class ="headpic" onclick= "$('#ImportPicInput').click();">
                            <img src="{$record['imageurl']}" />
                        </div>
                        <div class="faceimg_errmsg">
                        </div>
                    </div >
                    <input id="faceimg_id" type="hidden" name="faceimg_id" value="{$faceid}"/>
                    {/if}
                </div>
            </div>
        </div>
        <p></p>
        <script>
            //上传人脸图片
            $('.mui-image-uploader').on('change',$('#ImportPicInput'),function(){
                //$( "#importPicName").val($( "#ImportPicInput").val());
                var faceimg_id = $("#faceimg_id").val();
                $.ajaxFileUpload({
                    type: "POST",
                    url: "{php echo app_url('home/join/faceimgupload',array('activityid'=>$activity['id']))}",
                    data:{faceimg_id:faceimg_id},
                    secureuri : false,//是否启用安全提交，默认为false
                    fileElementId:'ImportPicInput',//文件选择框的id属性
                    dataType: 'json',//服务器返回的格式
                    async : false,
                    success: function(res){
                        if(res.errno==0){
                            $("#faceimg_id").val(res.data.faceimg_id);
                            $(".headpic img").attr("src", res.data.file_path);
                            $(".faceimg_errmsg").html("<br/><p style='color:#4cce75'>识别正确</p>");
                        }else{
                            var html = "<p style='color:#d06f6f'>" + res.errmsg + "</p>";
                            $(".faceimg_errmsg").html(html);
                        }
                    },
                    error: function (data, status, e){
                        console.log(2)
                    }
                });
            });
        </script>
        {/if}
        <ul class="mui-table-view mui-afterbefore-no">
            {if $activity['team']}
            <li class="mui-table-view-cell mui-pl15">
                <span style="line-height:2.5;">数量</span>
                <span class="mui-numbox mui-pull-right">
                <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
                <input name="teamnum" class="mui-input-numbox js-pay-team" type="number" value="{$teamnum}" pattern="[0-9]*">
                <button class="mui-btn mui-btn-numbox-plus" type="button">+</button></span>
            </li>
            {/if}

            {if $price >0}
            <input type="hidden" name="price" value="{$pay_price}" class="js-pay-price"/>
            <input type="hidden" name="aprice" value="{$price}" />
            {if $_W['plugin']['card']['config']['card_enable'] && $yearcard['buy'] && $activity['atype']==2 && !$activity['prize']['cardper']['enable'] && $price >0}
            <li class="mui-table-view-cell mui-pl15">单价<span class="mui-pull-right mui-del"><font class="mui-small mui-rmb"></font> <font class="mui-big">{$price}</font></span></li>
            <li class="mui-table-view-cell mui-pl15">{$yearcard['name']}专享价<span class="mui-pull-right"><font class="mui-small mui-rmb"></font> <font class="mui-big">{$activity['marketprice']}</font></span></li>
            {else}
            <li class="mui-table-view-cell mui-pl15">单价<span class="mui-pull-right"><font class="mui-small mui-rmb"></font> <font class="mui-big">{$price}</font></span></li>
            {/if}
            {if $pay_price >0}
            {if $afterMarketing['m1']}
            <li class="mui-table-view-cell mui-pl15">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted">满{$afterMarketing['max']}名：可享 {$afterMarketing['p']} 折</span></a>
            </li>
            {elseif $afterMarketing['m2']}
            <li class="mui-table-view-cell mui-pl15">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted">满{$afterMarketing['max']}名：立减 {$afterMarketing['p']} 元</span></a>
            </li>
            {elseif $afterMarketing['m3']}
            <li class="mui-table-view-cell mui-pl15">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted">VIP {$_W['member']['groupname']} 专享：{if $afterMarketing['orderMarket']['vip']['type']==1}{$afterMarketing['p']} 折{else}立减 {$afterMarketing['p']} 元{/if}</span></a>
            </li>
            {else}
            <li class="mui-table-view-cell mui-pl15" style="display:none">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted"></span></a>
            </li>
            {/if}
            <li class="mui-table-view-cell mui-pl15">小计<span class="mui-pull-right mui-text-rmb"><font class="mui-small mui-rmb"></font> <font class="mui-big js-pay-total">{php echo sprintf("%.2f", $pay_price + $afterMarketing['cardReduce'])}</font></span></li>
            {/if}
            {/if}
            {if $_W['plugin']['card']['config']['card_enable'] && $yearcard['buy'] && $activity['atype']==2 && $price >0}
            {if $activity['prize']['cardper']['enable']}
            <li class="mui-table-view-cell mui-pl15">
                <a href="#">{$yearcard['name']}专享优惠<span class="mui-badge mui-badge-inverted js-card-reduce">- {$afterMarketing['cardReduce']} 元</span></a>
            </li>
            {/if}
            {/if}
            {if $afterMarketing['m4']}
            <li class="mui-table-view-cell mui-pl15">
                积分抵扣
                <span style="display: inline-block;padding-right:60px;" class="mui-small mui-text-org">当前积分{$_W['member']['credit1']}，<span class="js-deduct">可消耗{$afterMarketing['orderMarket']['deduct'][0]}积分抵扣 ￥{$afterMarketing['orderMarket']['deduct'][1]}</span>，最高抵扣 ￥{$afterMarketing['deductMoney']}</span>
                <div class="mui-switch mui-switch-blue mui-switch-mini">
                    <div class="mui-switch-handle"></div>
                    <input type="hidden" name="dc" value=""  class="js-dc"/>
                </div>
            </li>
            {/if}
            {if $activity['costcredit']}
            <li class="mui-table-view-cell mui-media">
                <div class="mui-media-body">
                    积分消耗
                    <p class="mui-ellipsis mui-small mui-text-org">参与当前活动需要消耗 {$activity['costcredit']} 积分</p>
                </div>
            </li>
            {/if}
            {if $_W['_config']['joinmsg']}
            <li class="mui-table-view-cell">
                <textarea id="textarea" class="mui-input-clear" name="msg" placeholder="备注信息" style="padding:3px;"></textarea>
            </li>
            {/if}
        </ul>

    </div>
    {if $_W['_config']['agreement']}
    <div class="mui-content-padded" >
        <div class="mui-checkbox mui-agreement" style="font-size: 14px;" >
            <div style="display: inline-block" class="js-popover" data-popover='agreement' onclick="showp()">
                <input name="agreement" value="1" type="checkbox" ><label>已阅读并同意《<a style="color: #04be02;">用户报名协议</a>》</label>
            </div>
        </div>
    </div>
    {/if}
    </div>
</form>
{template 'activity/popover'}
<script type="text/javascript">
    function showp(){
        document.getElementById('pophei').style.setProperty('display','block');
    }
    $('.js-close').on('tap',function(e){
        document.getElementById('pophei').style.setProperty('display','none');
    });

        {if ($activity['joinetime']<date("Y-m-d H:i:s",time()))}
        var btnArray = ['确定'];
        var msg='当前活动已截止报名';
        mui.confirm(msg,'',btnArray, function(e) {
            location.href ="javascript:history.go(-1)";
        });
        {/if}
        {if ($activity['joinstime']>date("Y-m-d H:i:s",time()))}
        var btnArray = ['查看记录', '确定'];
        var msg='当前活动不允许重复报名';
        mui.confirm(msg,'',btnArray, function(e) {
            if (e.index != 1) {
                location.href = '{php echo app_url('home/index/myapply')}';
            }else{
                location.href ="javascript:history.go(-1)";
            }
        });
        {/if}
        {if !empty($findUser) && !$activity['hasjoin']}
        var btnArray = ['查看记录', '确定'];
        var msg='当前活动不允许重复报名';
        mui.confirm(msg,'',btnArray, function(e) {
            if (e.index != 1) {
                location.href = '{php echo app_url('home/index/myapply')}';
            }else{
                location.href ="javascript:history.go(-1)";
            }
        });
        {/if}
    mui('.mui-scroll-wrapper').scroll();
    //省级地址码校验
    var checkProv = function (val) {
        var pattern = /^[1-9][0-9]/;
        var provs = {11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门"};
        if(pattern.test(val)) {
            if(provs[val]) {
                return true;
            }
        }
        return false;
    }
    //出生日期码校验
    var checkDate = function (val) {
        var pattern = /^(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)$/;
        if(pattern.test(val)) {
            var year = val.substring(0, 4);
            var month = val.substring(4, 6);
            var date = val.substring(6, 8);
            var date2 = new Date(year+"-"+month+"-"+date);
            if(date2 && date2.getMonth() == (parseInt(month) - 1)) {
                return true;
            }
        }
        return false;
    }
    //校验码校验
    var checkCode = function (val) {
        var p = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
        var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
        var code = val.substring(17);
        if(p.test(val)) {
            var sum = 0;
            for(var i=0;i<17;i++) {
                sum += val[i]*factor[i];
            }
            if(parity[sum % 11] == code.toUpperCase()) {
                return true;
            }
        }
        return false;
    }
    //身份证规则校验
    var checkID = function (val) {
        if(checkCode(val)) {
            var date = val.substring(6,14);
            if(checkDate(date)) {
                if(checkProv(val.substring(0,2))) {
                    return true;
                }
            }
        }
        return false;
    }

    $(function(){

        $('.mui-content input').focus(function(){
                $('.mui-bar-footer').css('display','none');

        })
        $('.mui-content input').blur(function(){

                $('.mui-bar-footer').css('display','block');
        })

        $('input[type=text]').each(function(key){
            if ($(this).attr("readonly")) $(this).attr('onfocus','this.blur()');
        });
        var oldMoble = "{$profile['mobile']}";
        $('.js-check-mobile').on("tap",function(e) {
            if (!$('#smscode').parent().hasClass('active')){
                $('#smscode').parent().show().addClass('active');
                $('#mobile').removeAttr('onfocus');
                $(this).find('span').text('取消变更');
            }else{
                $('#smscode').parent().hide().removeClass('active');
                $('#mobile').attr('onfocus','this.blur()').val(oldMoble).blur();
                $(this).find('span').text('点此变更');
            }
        });
        {if $afterMarketing['m4']==1}
        //开关
        $('.mui-switch').on('tap',function(e){
            var teamnum = $('.js-pay-team').val();
            if ($(this).hasClass("mui-active")){
                $(this).find('input').val('yes');
                getPrice(teamnum, 'yes');
            }else{
                $(this).find('input').val('');
                getPrice(teamnum, '');
            }
            //console.log("你启动了开关");
        });
        {/if}
            //报名人数控制
            var payprice, aprice ={$price},teamquota=parseInt({$activity['teamquota']}),quota=parseInt({$quota}),joinnum=parseInt({$joinnum});
            var forquota = quota?quota-joinnum:0;
            $("input.js-pay-team").bind('input propertychange, change', function(e) {
                e.stopPropagation();
                if ($(this).val()==0){
                    $(this).val(1);
                }
                //判断名额
                if($(this).val() > forquota && quota > 0){
                    $(this).val(forquota);
                    util.alert('已超出剩余数量范围', ' ', function() {
                        $(".js-pay-team").val(forquota);
                    });
                }
                //团名额限制
                if ($(this).val() > teamquota && teamquota > 0){
                    $(".js-pay-team").val(teamquota);
                    util.alert('已达该票输入最大值', ' ', function() {
                        $('.js-pay-price').val(payprice);
                    });
                }
                //读取价格
                if(aprice>0){
                    var teamnum = $(this).val(),dc = $('.js-dc').val();
                    getPrice(teamnum, dc);
                }
            });

            {if $_W['_config']['smsswitch']}
            var issend=true;//短信初始控制开关
            if($.getCookie("captcha")){
                var count = $.getCookie("captcha");
                var btn = $('#get_code');
                btn.html(count+"秒后可重发");
                issend=false;
                var resend = setInterval(function(){
                    count--;
                    if (count > 0){
                        btn.html(count+"秒后可重发");
                        $.setCookie("captcha", count);
                    }else {
                        clearInterval(resend);
                        btn.html("获取验证码");
                        issend=true;
                        $.delCookie("captcha");
                    }
                }, 1000);
            }
            $("#get_code").on("tap",function() {
                if(issend){
                    //验证电话号码手机号码
                    var phoneObj = document.getElementById('mobile');
                    if (phoneObj.value != ""){
                        var phoneVal=phoneObj.value;
                        var p1 = /^1[0-9]{10}$/;
                        var me = false;
                        if (p1.test(phoneVal)) me=true;
                        if (!me){
                            phoneObj.value='';
                            util.alert('请输入正确的手机号码', ' ', function() {
                                phoneObj.focus();
                            });
                            return false;
                        }else{
                            issend=false;
                            var btn = $(this);
                            var count = 60;
                            var resend = setInterval(function(){
                                count--;
                                if (count > 0){
                                    btn.html(count+"秒后可重发");
                                    $.setCookie("captcha", count);
                                }else {
                                    clearInterval(resend);
                                    issend=true;
                                    btn.html("获取验证码");
                                    $.delCookie("captcha");

                                }
                            }, 1000);
                            $.ajax({
                                type: 'POST',
                                url: "{php echo app_url('api/sendsms/code')}&mobile="+phoneVal,
                                dataType: 'json',
                                success: function(data){
                                    console.log(data);
                                    if(data.hasOwnProperty("result") || data.Code=='OK'){
                                        util.toast('发送成功');
                                    }else{
                                        var err_msg = data.hasOwnProperty("Message") ? data.Message : data.sub_msg;
                                        util.alert(err_msg, ' ', function() {return false;});
                                    }
                                },
                                error:function(){
                                    util.alert('服务器错误, 请联系官方人员', ' ', function() {return false;});
                                }
                            });
                        }
                    }else{
                        util.toast('手机不能为空',"","error");
                        return false;
                    }
                }
            });
            {/if}
            });
    //数据发送
    function postData(){
        $.post("{php echo app_url('home/join/join')}", $("#formdata").serialize(), function(data){
           console.log(data);
            if(data.errno == 1){
                util.alert(data.errmsg); return false;
            }
            else if (data.errno==0){
                if (data.is_pay)
                    location.href = "{php echo app_url('home/index/pay')}&recordid="+data.recordid;
                else
                    location.href = "{php echo app_url('home/index/free')}&recordid="+data.recordid;
            }else{
                util.tips('服务器错误！');
            }
        },"json");
    }
    //表单变化
    function formChange(id){
    location.href = "{php echo app_url('home/join/display')}&activityid={$activityid}&proid={$proid}&recordid={$_GPC['recordid']}&cid="+id+"";
    }
    //校验表单
    function check(form) {
        var patt = new RegExp(/\s+/g);
        var checksubmit = false,value='';
        {if $sysform['realname']['show']!='0'}
        if ($.trim(form['member[realname]'].value) == '') {
            util.alert('请输入姓名', ' ', function() {
                $(form['member[realname]']).focus();
            });
            return false;
        }
        {/if}
            {if $sysform['mobile']['show']!='0'}
            if (!form['member[mobile]'].value) {
                util.alert('请输入手机号', ' ', function() {
                    $(form['member[mobile]']).focus();
                });
                return false;
            }else{
                var mobile = $('#mobile').val();
                var pattern = /^1[0-9]{10}$/;

                if (!pattern.test(mobile)) {
                    util.alert('手机号不合法', ' ', function() {
                        $(form['member[mobile]']).focus();
                    });
                    return false;
                }
            }
            {/if}
                {if !empty($sysform)}
                {loop $sys_form $k $v}
                {if $k=='gender' && ($v['show']=='' || $v['show']) && $v['need']}
                if (!form['{$k}'].value) {
                    util.alert("请选择{$v['title']}", ' ', function() {
                        $(".mui-gender-picker").trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='age' && $v['need']}
                if (!form['member[{$k}]'].value) {
                    util.alert("请输入{$v['title']}", ' ', function() {
                        $(form['member[{$k}]']).trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='birthyear' && ($v['show']=='' || $v['show']) && $v['need']}
                if (form['birth[year]'].value=='0') {
                    util.alert("选择{$v['title']}", ' ', function() {
                        $("input[name='birth']").trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='idcard' && $v['need']}
                var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
                if (!pattern.test($(form['member[{$k}]']).val())){
                    util.alert("{$v['title']}不合法", ' ', function() {
                        $(form['member[{$k}]']).focus();
                    });
                    checksubmit = false;
                    return false;
                }

                var id_card = $(form['member[{$k}]']).val();
                if(checkID(id_card) == false){
                    util.alert("{$v['title']}不合法", ' ', function() {
                        $(form['member[{$k}]']).focus();
                    });
                    checksubmit = false;
                    return false;
                }

                {elseif $k=='education' && $v['need']}
                if (!form['{$k}'].value) {
                    util.alert("请选择{$v['title']}", ' ', function() {
                        $(".mui-education-picker").trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='company' && $v['need']}
                if (!form['member[{$k}]'].value) {
                    util.alert("请输入{$v['title']}", ' ', function() {
                        $(form['member[{$k}]']).trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='position' && $v['need']}
                if (!form['member[{$k}]'].value) {
                    util.alert("请输入{$v['title']}", ' ', function() {
                        $(form['member[{$k}]']).trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='occupation' && $v['need']}
                if (!form['member[{$k}]'].value) {
                    util.alert("请输入{$v['title']}", ' ', function() {
                        $(form['member[{$k}]']).trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='email' && $v['need']}
                if (!form['member[{$k}]'].value) {
                    util.alert("请输入{$v['title']}", ' ', function() {
                        $(form['member[{$k}]']).trigger('tap');
                    });
                    return false;
                }
                {elseif $k=='resideprovince' && ($v['show']=='' || $v['show']) && $v['need']}
                if (!form['reside[province]'].value) {
                    util.alert("请选择{$v['title']}", ' ', function() {
                        $(".mui-district-picker-reside").trigger('tap');
                    });
                    return false;
                }
                {/if}
                    {/loop}
                        {/if}

                            {if $_W['_config']['smsswitch']}
                            var check_tel = $('#smscode').parent().hasClass('active');
                            if (check_tel){
                                if (!form['smscode'].value) {
                                    util.alert('请输入验证码', ' ', function() {
                                        $("input[name='smscode']").focus();
                                    });
                                    return false;
                                }else{
                                    var smscode = $('#smscode').val();
                                    if ($.getCookie("sms_code")!=smscode) {
                                        util.alert('验证码不正确', ' ', function() {
                                            $("input[name='smscode']").focus();
                                        });
                                        return false;
                                    }else if(form['member[mobile]'].value!=$.getCookie("sms_mobile")){
                                        util.alert('当前手机号与验证码不符', ' ', function() {
                                            $(form['member[mobile]']).focus();
                                        });
                                        return false;
                                    }
                                }
                            }
                            {/if}

                                if($(form['essential']).length){
                                    $(form['essential']).each(function(){
                                        var inputkey = $(this).val();
                                        var formtype = $(this).data('type');
                                        var inputName = 'form_item_val_'+$(this).val();
                                        if (inputkey!=''){
                                            if ($(form[inputName+'[]']).length || formtype=='6'){
                                                inputName = inputName+'[]';
                                                if ($(form[inputName]).attr("type")=='checkbox' && $('input:checkbox[name="'+inputName+'"]:checked').length == 0) {
                                                    util.alert($(this).attr("title")+'为必选项', ' ', function() {
                                                        $(form[inputName]).focus();
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }else if(formtype=='6' && !$(form[inputName]).length){
                                                    util.alert($(this).attr("title")+'不能为空', ' ', function() {});
                                                    checksubmit = false;
                                                    return false;
                                                }
                                            }else if($(form[inputName+'[province]']).length){
                                                if (!form[inputName+'[province]'].value) {
                                                    util.alert($(this).attr("title")+'为必选项', ' ', function() {
                                                        $('.mui-district-picker-'+inputName).trigger('tap');
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }
                                            }else{
                                                if ($.trim(form[inputName].value)=="" && $(form[inputName]).attr("type")!='radio' && !$(form[inputName]).next().val()) {
                                                    var msg = $(form[inputName]).siblings('.mui-calendar-picker'+inputkey).length?'为必选项':'不能为空';
                                                    util.alert($(this).attr("title")+msg, ' ', function() {
                                                        if (formtype=='3' || formtype=='4'){
                                                            $(form[inputName]).focus();
                                                        }
                                                        $(form[inputName]).siblings('.mui-calendar-picker'+inputkey).trigger('tap')
                                                        $(form[inputName]).trigger('tap');
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }else if($(form[inputName]).attr("type")=='radio' && $('input:radio[name="'+inputName+'"]:checked').length == 0){
                                                    util.alert($(this).attr("title")+'为必选项', ' ', function() {
                                                        $(form[inputName]).focus();
                                                        $(form[inputName]).trigger('tap');
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }
                                            }
                                        }else{
                                            inputName = "member["+formtype+"]";
                                            var typeStr = "education,birthyear,resideprovince,constellation,zodiac,bloodtype";
                                            if (typeStr.indexOf(formtype)>-1){
                                                if (formtype=='birthyear' && $(form['birth']).val()==""){
                                                    util.alert($(this).attr("title")+'为必选项', ' ', function() {
                                                        $(form['birth']).trigger('tap');
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }else if(formtype=='resideprovince' && $('.mui-district-picker-reside').val()==""){
                                                    util.alert($(this).attr("title")+'为必选项', ' ', function() {
                                                        $('.mui-district-picker-reside').trigger('tap');
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }else if ($(form[formtype]).val()==""){
                                                    util.alert($(this).attr("title")+'为必选项', ' ', function() {
                                                        $(form[formtype]).siblings('.mui-'+formtype+'-picker').trigger('tap');
                                                    });
                                                    checksubmit = false;
                                                    return false;
                                                }
                                            }else if($.trim($(form[inputName]).val())=="" && $(form[inputName]).length){
                                                util.alert($(this).attr("title")+'不能为空', ' ', function() {
                                                    $(form[inputName]).focus();
                                                });
                                                checksubmit = false;
                                                return false;
                                            }else{
                                                if( formtype == 'idcard'){
                                                    var id_card = $(form[inputName]).val();
                                                    var cn_card = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; //身份证
                                                    var hk_card = /^([A-Z]\d{6,10}(\(\w{1}\))?)$/; //港澳通行证
                                                    var tw_card = /^\d{8}|^[a-zA-Z0-9]{10}|^\d{18}$/; //台湾通行证
                                                    var pp_card = /^([a-zA-z]|[0-9]){5,17}$/; //护照
                                                    var jg_card = /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/; //军官证
                                                    var test=0;
                                                    if (!cn_card.test(id_card)){
                                                        test++;
                                                    }
                                                    if (!hk_card.test(id_card)){
                                                        test++;
                                                    }
                                                    if (!tw_card.test(id_card)){
                                                        test++;
                                                    }
                                                    if (!pp_card.test(id_card)){
                                                        test++;
                                                    }
                                                    if (!jg_card.test(id_card)){
                                                        test++;
                                                    }

                                                    if(test==5){
                                                        util.alert($(this).attr("title")+'不合法', ' ', function() {
                                                            $(form[inputName]).focus();
                                                        });
                                                        checksubmit = false;
                                                        return false;
                                                    }
                                                }

                                            }
                                        }
                                        checksubmit = true;
                                    });
                                }else{
                                    checksubmit = true;
                                }
                                //if (form['gender'].value=='') {
                                //	util.alert('请选择您的性别', ' ', function() {
                                //		$(".js-user-options").trigger('tap');
                                //	});
                                //	return false;
                                //}
                                if (checksubmit){
                                    {if $_W['_config']['agreement']}
                                    if ($('input:checkbox[name="agreement"]:checked').length == 0) {
                                        util.alert('请阅读并同意报名协议', ' ', function() {
                                        });
                                        return false;
                                    }
                                    {/if}
                                        $.ajax({
                                            type: 'POST',
                                            url: "{php echo app_url('home/join/validquota',array('activityid'=>$activityid,'optionid'=>$optionid))}&teamnum=" + $('.js-pay-team').val(),
                                            dataType: 'json',
                                            async:false,
                                            success: function(data){
                                                if(!data.errno){
                                                    checksubmit = true;
                                                }else{
                                                    checksubmit=false;
                                                    setTimeout(function() {
                                                        util.alert(data.message, ' ', function() {return false;});
                                                    },450);
                                                }
                                            },
                                            error:function(){
                                                checksubmit=false;
                                                setTimeout(function() {
                                                    util.alert('服务器加载错误, 请联系主办方', ' ', function() {return false;});
                                                },450);
                                            }
                                        });
                                    }
                                    if (checksubmit){
                                        {if $activity['costcredit']}
                                        util.confirm("参与当前活动需要消耗 {$activity['costcredit']} 积分", ' ',['取消', '确认'], function(e) {
                                            if (e.index == 1){
                                                postData();
                                            }
                                        });
                                        {else}
                                        postData();
                                        {/if}
                                        }
                                        return false;
                                    }
//价格计算
                                    function getPrice(teamnum, dc){
                                        $.post("{php echo app_url('home/join/getprice',array('activityid'=>$activityid,'optionid'=>$optionid))}", {teamnum:teamnum,dc:dc}, function(data){
                                            console.log(data);
                                            if(!data.errno){
                                                if (data.params.m1 || data.params.m2 || data.params.m3){
                                                    $('.js-marketing').parent().show();
                                                    if (data.params.m3){
                                                        if (data.params.orderMarket.vip.type==1){
                                                            $('.js-marketing').find('span').html("VIP {$_W['member']['groupname']} 专享："+data.params.p+' 折');
                                                        }else{
                                                            $('.js-marketing').find('span').html("VIP {$_W['member']['groupname']} 立减："+data.params.p+' 元');
                                                        }
                                                    }else{
                                                        var maxmeet=0, obj_ = new Object();
                                                        $("#marketing .mui-input-row").each(function(key){
                                                            $(this).find('input').attr('disabled',"true");
                                                            $(this).find('input').removeAttr("checked");
                                                            $(this).addClass('mui-disabled');
                                                            if (teamnum >= $(this).data("meet")){
                                                                if ($(this).data("meet") > maxmeet) obj_ = this;
                                                                maxmeet = $(this).data("meet")>maxmeet ? $(this).data("meet"):maxmeet;
                                                            }else{maxmeet=0}
                                                        });
                                                        $(obj_).find('input').prop("checked",'true');
                                                        $(obj_).removeClass('mui-disabled');
                                                        if (data.params.m1)
                                                            $('.js-marketing').find('span').html('满'+data.params.max+'名：可享 '+data.params.p+' 折');
                                                        if (data.params.m2)
                                                            $('.js-marketing').find('span').html('满'+data.params.max+'名：立减 '+data.params.p+' 元')
                                                    }

                                                }else{
                                                    $('.js-marketing').parent().hide();
                                                }

                                                var pay_total = data.params.pay_price;
                                                if (dc){
                                                    pay_total = (parseFloat(data.params.pay_price) + parseFloat(data.params.orderMarket.deduct[1])).toFixed(2);
                                                    $('.js-deduct').text('可消耗'+data.params.orderMarket.deduct[0]+'积分抵扣 ￥'+data.params.orderMarket.deduct[1]);
                                                }
                                                pay_total = data.params.cardReduce ? parseFloat(pay_total) + parseFloat(data.params.cardReduce) : parseFloat(pay_total);
                                                $('.js-pay-total').text(pay_total.toFixed(2));
                                                $('.js-card-reduce').text('- '+data.params.cardReduce+' 元');
                                                $('.js-pay-totaled').text(parseFloat(data.params.pay_price).toFixed(2));
                                                $('.js-pay-price').val(parseFloat(data.params.pay_price).toFixed(2));
                                                $("input[name='token']"). val(data.params.token);
                                            }else{

                                            }
                                        },"json");
                                    }

                                    {if $_W['container']=='wechat'}
                                    var appid = '{$_W['account']['jssdkconfig']['appId']}';
                                    var timestamp = '{$_W['account']['jssdkconfig']['timestamp']}';
                                    var nonceStr = '{$_W['account']['jssdkconfig']['nonceStr']}';
                                    var signature = '{$_W['account']['jssdkconfig']['signature']}';

                                    wx.config({
                                        debug: false,
                                        appId: appid,
                                        timestamp: timestamp,
                                        nonceStr: nonceStr,
                                        signature: signature,
                                        jsApiList: ['checkJsApi','chooseImage','previewImage','uploadImage','downloadImage']
                                    });

                                    wx.ready(function(){
                                        // 5 图片接口
                                        var images = {
                                            localId: [],
                                            serverId: []
                                        };
                                        document.querySelector('#chooseImage').onclick = function () {
                                            wx.chooseImage({
                                                count: 1,
                                                success: function (res) {
                                                    images.localId = res.localIds;
                                                    //alert('已选择 ' + res.localIds.length + ' 张图片');
                                                    $(function(){
                                                        var imglist = "";
                                                        $.each(res.localIds, function(i, n){
                                                            imglist+='<li ><img src="'+n+'" style="height:150px;" /></li>';
                                                            //$("#errormsg").append("res.localIds:"+n+"<br />");
                                                        });
                                                        $("#imageContainer > ul").html(imglist);
                                                        $("#chooseImage").removeClass("mui-btn-success");
                                                        $("#chooseImage").addClass("mui-btn-orange");
                                                        $("#chooseImage").text("更换图片");
                                                    });
                                                    uploadimg(images.localId);
                                                }
                                            });
                                        };

                                        function uploadimg(localIds){
                                            //$("#errormsg").append("<br />localIds length:"+localIds.length);
                                            var localId = localIds.pop();
                                            wx.uploadImage({
                                                localId: localId,
                                                //isShowProgressTips: 1,
                                                success: function (res) {
                                                    images.serverId = []; //把值清空掉，只需一个
                                                    images.serverId.push(res.serverId);
                                                    //$("#errormsg").append("<br />"+res.serverId+",");
                                                    if(localIds.length > 0){
                                                        uploadimg(localIds);
                                                    }
                                                    else{
                                                        if(window.XMLHttpRequest){
                                                            xmlHttpRequest=new XMLHttpRequest();
                                                        }else{
                                                            xmlHttpRequest=new ActiveXObject("MSXML2.XMLHTTP.3.0");//("Microsoft.XMLHTTP");
                                                        }
                                                        //$("#errormsg").append("<br />准备处理，请等待...");
                                                        serverIds=images.serverId;
//                        document.getElementById("serverIds").value = JSON.stringify(serverIds);
                                                        document.getElementById("serverIds").value = serverIds[0];
                                                        //$("#serverIds").val(JSON.stringify(serverIds));
                                                        //getimgtoserver(serverIds);
                                                    }
                                                },
                                                fail: function (res) {
                                                    console.log(JSON.stringify(res));
                                                    alert("上传失败，请稍候重试");
                                                }
                                            });
                                        }
                                    });
                                    {/if}
</script>
</body>
</html>
